package demo3;

class Solution {
    public int countSegments(String s) {
        if(s == null) {
            return 0;
        }
        if(s.length() == 0) {
            return 0;
        }
        String[] strings = s.split(" "); 
        int count = 0;
        for(String str : strings) {
            if(str.length() != 0) {
                count++;
            }
        }
        return count;
    }
}